unit uOrg;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
  ADODB, cxGridLevel, cxClasses, cxGridCustomView, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxGrid, ExtCtrls,uDB, Grids, DBGrids,
  cxTL, cxMaskEdit, cxTLdxBarBuiltInMenu, cxInplaceContainer, cxDBTL, cxTLData,
  Menus, StdCtrls, cxButtons;

type
  TfrmOrgManager = class(TForm)
    pnl1: TPanel;
    ds1: TDataSource;
    qryOrg: TADOQuery;
    cxstylrpstry1: TcxStyleRepository;
    cxstyl1: TcxStyle;
    lst1: TcxDBTreeList;
    cxdbtrlstclmnlst1ID: TcxDBTreeListColumn;
    cxdbtrlstclmnlst1I_PARENT_ID: TcxDBTreeListColumn;
    cxdbtrlstclmnlst1C_CODE: TcxDBTreeListColumn;
    cxdbtrlstclmnlst1C_NAME_ZH: TcxDBTreeListColumn;
    cxdbtrlstclmnlst1C_NAME_EN: TcxDBTreeListColumn;
    cxdbtrlstclmnlst1C_ZIP: TcxDBTreeListColumn;
    btn1: TcxButton;
    btn2: TcxButton;
    btn3: TcxButton;
    procedure FormShow(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmOrgManager: TfrmOrgManager;

implementation
 uses uOrgEdit;
{$R *.dfm}

procedure TfrmOrgManager.btn1Click(Sender: TObject);
begin
  qryOrg.Delete;
end;

procedure TfrmOrgManager.btn2Click(Sender: TObject);
var
  frmOrgEdit :TfrmOrgEdit;
  iParent : Integer;
begin
  iParent := qryOrg.FieldValues['id'];
  frmOrgEdit := TfrmOrgEdit.Create(self);
  try
    qryOrg.Append;
    qryOrg.FieldValues['I_PARENT_ID'] := iParent;
    frmOrgEdit.qryOrg := qryOrg;
    frmOrgEdit.ShowModal;
  finally
    frmOrgEdit.Free;
  end;
end;

procedure TfrmOrgManager.btn3Click(Sender: TObject);
var
  frmOrgEdit :TfrmOrgEdit;
begin
  frmOrgEdit := TfrmOrgEdit.Create(self);
  try
    qryOrg.Edit;
    frmOrgEdit.qryOrg := qryOrg;
    frmOrgEdit.ShowModal;
  finally
    frmOrgEdit.Free;
  end;
end;

procedure TfrmOrgManager.FormShow(Sender: TObject);
begin
  qryOrg.Open;
end;

end.
